<!DOCTYPE html>
<html lang="zh-cn">
<#include "../include/resource-head.ftl"/>
<link rel="stylesheet" href="/themes/plugins/fileinput/css/fileinput.min.css">
<body>
<#include "../include/common-header.ftl"/>
<div class="container col-center-block">
    <div class="order-list">
    <#list pageInfo.list as item>
        <div class="order-item">
            <div class="order-item-top">
                <strong>${item.addtime?string('yyyy-MM-dd HH:mm:ss')}</strong>&nbsp;&nbsp;&nbsp;
                <span>订单号:&nbsp;${item.orderno!}</span>
                <a href="/order/detail/${item.id}" class="pull-right">订单详情</a>
            </div>
            <div class="order-item-detail">
                <div class="col-xs-4">
                    <a href="/goods/detail/${item.goodsId}">
                        <img src="/data/${item.goodsImg!}" height="80px" width="80px">
                        <span>${item.goodsName!}</span>
                    </a>
                </div>
                <div class="col-xs-1">
                    <span class="text-red">￥${item.salary?string("##0.00")}</span>
                </div>
                <div class="col-xs-1">
                    <span>${item.count}</span>
                </div>
                <div class="col-xs-1">
                    <span class="text-red">￥${item.total?string("##0.00")}</span>
                </div>
                <div class="col-xs-1">
                    <span>${item.receiveuser!}</span>
                </div>
                <div class="col-xs-2 text-center" style="border-left: 1px solid #ececec;">
                    <#if item.status == 0>订单取消
                    <#elseif item.status == 1>代付款
                    <#elseif item.status == 2>待发货
                    <#elseif item.status == 3>待收货
                    <#elseif item.status == 4>待评价
                    <#elseif item.status == 5>订单完成</#if>
                </div>
                <div class="col-xs-2" style="border-left: 1px solid #ececec; text-align: center">
                    <#if item.status == 1><a href="#" onclick="pay('${item.id}')" class="btn btn-primary btn-sm">付款</a>
                    <#elseif item.status == 3><a href="#" onclick="receive('${item.id}')" class="btn btn-warning btn-sm">确认收货</a>
                    <#elseif item.status == 4><a href="#" class="btn btn-success btn-sm" onclick="eval('${item.id}')">去评价</a>
                    <#elseif item.status == 5>${item.evaluatetime?string('yyyy-MM-dd HH:mm:ss')}
                    </#if>
                </div>
            </div>
        </div>
    </#list>
    </div>
</div>

<!-- Modal -->
<div class="modal fade bs-example-modal-sm" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">评价订单</h4>
            </div>
            <div class="modal-body">
               <form action="/evaluate/save" method="post">
                   <input type="hidden" value="" id="orderId" name="orderId"/>
                   <textarea class="form-control" name="content" cols="5" rows="5" id="content"></textarea>
               </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="submit" class="btn btn-primary" onclick="evaluate_submit()">提交评价</button>
            </div>
        </div>
    </div>
</div>

<#include "../include/common-foot.ftl"/>
</body>
<#include "../include/resource-script.ftl"/>
<script>
    function pay(id){
        if(confirm("确定要付款吗？")){
            location.href = "/order/pay?id="+id;
        }
    }
    function receive(id){
        if(confirm("确定已经收到了吗？")){
            location.href = "/order/receive?id="+id;
        }
    }
    function eval(id){
        $("#orderId").val(id);
        $("#myModal").modal("show");
    }
    function evaluate_submit(){
        if($("#content").val().length == 0){
            alert("请输入评价内容");
        }else{
            $("form").submit();
        }
    }
</script>
</html>